/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cw.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author VinhTC
 */
@Entity
@Table(name = "tblPuzzle")
@NamedQueries({
    @NamedQuery(name = "Puzzle.findAll", query = "SELECT p FROM Puzzle p"),
    @NamedQuery(name = "Puzzle.findByPuzzleId", query = "SELECT p FROM Puzzle p WHERE p.puzzleId = :puzzleId"),
    @NamedQuery(name = "Puzzle.findByPuzzleName", query = "SELECT p FROM Puzzle p WHERE p.puzzleName = :puzzleName"),
    @NamedQuery(name = "Puzzle.findByCreated", query = "SELECT p FROM Puzzle p WHERE p.created = :created"),
    @NamedQuery(name = "Puzzle.findByStatus", query = "SELECT p FROM Puzzle p WHERE p.status = :status")})
public class Puzzle implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "PuzzleId")
    private Integer puzzleId;
    @Column(name = "PuzzleName")
    private String puzzleName;
    @Basic(optional = false)
    @Column(name = "Created")
    private boolean created;
    @Basic(optional = false)
    @Column(name = "Status")
    private boolean status;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "puzzle")
    private List<Question> questionList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "puzzle")
    private List<GameResult> gameResultList;
    @JoinColumn(name = "SubjectId", referencedColumnName = "SubjectId")
    @ManyToOne(optional = false)
    private Subject subject;
    @JoinColumn(name = "SizeId", referencedColumnName = "SizeId")
    @ManyToOne(optional = false)
    private PuzzleSize puzzleSize;
    @JoinColumn(name = "LevelId", referencedColumnName = "LevelId")
    @ManyToOne(optional = false)
    private Level level;

    public Puzzle() {
    }

    public Puzzle(Integer puzzleId) {
        this.puzzleId = puzzleId;
    }

    public Puzzle(Integer puzzleId, boolean created, boolean status) {
        this.puzzleId = puzzleId;
        this.created = created;
        this.status = status;
    }

    public Integer getPuzzleId() {
        return puzzleId;
    }

    public void setPuzzleId(Integer puzzleId) {
        this.puzzleId = puzzleId;
    }

    public String getPuzzleName() {
        return puzzleName;
    }

    public void setPuzzleName(String puzzleName) {
        this.puzzleName = puzzleName;
    }

    public boolean getCreated() {
        return created;
    }

    public void setCreated(boolean created) {
        this.created = created;
    }

    public boolean getStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    public List<Question> getQuestionList() {
        return questionList;
    }

    public void setQuestionList(List<Question> questionList) {
        this.questionList = questionList;
    }

    public List<GameResult> getGameResultList() {
        return gameResultList;
    }

    public void setGameResultList(List<GameResult> gameResultList) {
        this.gameResultList = gameResultList;
    }

    public Subject getSubject() {
        return subject;
    }

    public void setSubject(Subject subject) {
        this.subject = subject;
    }

    public PuzzleSize getPuzzleSize() {
        return puzzleSize;
    }

    public void setPuzzleSize(PuzzleSize puzzleSize) {
        this.puzzleSize = puzzleSize;
    }

    public Level getLevel() {
        return level;
    }

    public void setLevel(Level level) {
        this.level = level;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (puzzleId != null ? puzzleId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Puzzle)) {
            return false;
        }
        Puzzle other = (Puzzle) object;
        if ((this.puzzleId == null && other.puzzleId != null) || (this.puzzleId != null && !this.puzzleId.equals(other.puzzleId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cw.entity.Puzzle[puzzleId=" + puzzleId + "]";
    }

}
